<template>
  <el-dialog
    title="GPT模型"
    width="30%"
    draggable
    :close-on-press-escape = false
    :close-on-click-modal	= false
    v-model="show"
    @before-close="close"
  >
    <el-form label-width="120px" :model="GPTForm" ref="GPTForm">
      <el-form-item label='选择模型:'>
        <el-select v-model="GPTForm.model" placeholder="请选择AI模型 " :popper-class="color === 'night' ? 'nightClass' : ''">
          <el-option label="GPT-3.5" value="3.5"></el-option>
          <el-option label="GPT-4.0" value="4.0"></el-option>
        </el-select>
      </el-form-item>
      <div style="display:flex;justify-content: flex-end;">
        <el-button v-if="!loading" style="" type="primary" icon="Position" @click="submit">
          确定
        </el-button>
      </div>
    </el-form>
  </el-dialog>
</template>

<script>
export default {
  props: {
    GPTDialog:{
      type: Boolean,
      default: () => false
    },
    loading:{
      type: Boolean,
      default: () => false
    },
    name:{
      type: String,
      default: () => ''
    },
    Action: {
      type: Number,
      default: () => 1
    },
    pictureList:{
      type: Array,
      default: () => []
    },
    GPTForm:{
      type: Object,
      default: () => {}
    }
  },
  mounted(){
    this.color = localStorage.getItem('isNightMode') || 'night'
  },
  watch:{
    GPTDialog(value){
      this.show = value
    },
    pictureList(value){
      let previewList = []
      value.map(item => {
        previewList.push(item.url)
      })
      this.previewList = previewList
    },
  },
  data(){
    return{
      previewList: [],
      show: false,
      color:''
    }
  },
  methods:{
    translation(result){
      if(result){
        this.GPTForm[result.binding] = result.translation
      }
    },
    submit(){
      if(!this.GPTForm.model){
        this.$message.error('请选择模型')
        return
      }
      this.$emit('submit', this.GPTForm.model)
    },
    close(){
      this.$emit('closeGPTDialog')
    },
  }
}
</script>

<style lang="scss" scoped>
  .relatedConditions{
    display: flex;
    align-items: center;
    height: 95px;
    .conditionname{
      width: 120px;
      height: 30px;
      line-height: 30px;
      color: #409EFF;
      border: 2px solid #409EFF;
      text-align: center;
      border-radius: 20px;
      margin-right: 20px;
    }
  }
  .dialog-footer{
    display: inline-block;
    display: flex;
    align-items: center;
    padding-bottom: 40px;
    .demo-image{
      display: flex;
      .block{
        width: 300px;
      }
    }
  }
</style>
<style>
.el-dialog__header {
  padding: 0;
  margin: 0;
}
.el-dialog.is-draggable .el-dialog__header{
  border-bottom: 1px solid #409EFF;
}
.el-dialog__title{
  display: inline-block;
  width: 180px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  background: #409EFF;
  color: #fff;
}
.rounded-checkbox .el-checkbox__inner {
  border-radius: 50%;
}
.rounded-checkbox .el-checkbox__input.is-checked .el-checkbox__inner {
  background-color: #409EFF;
  border-color: #409EFF;
}
.el-checkbox__input.is-checked + .el-checkbox__label{
  color: #409EFF;
}
.el-dialog__footer {
  margin: 0;
  padding: 0;
  text-align: left;
  margin-left: 20px;
  font-size: 14px;
}
</style>
